#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author:lxl

import requests
from lxml import etree

class WannianHouse:
    def __init__(self):
        self.baseUrl="https://www.335500.cn/ershoufang"



if __name__ == '__main__':

    house = WannianHouse()
    res = requests.get(house.baseUrl)
    res.encoding = 'UTF-8'
    html = etree.HTML(res.text)  # 初始化生成一个XPath解析对象

    #

    result = html.xpath('//*[@id="formlist"]/ul/li')
    for i in result:
        try:
            #//*[@id="formlist"]/ul/li[7]/div/div/div[6]/div[1]/span  //*[@id="formlist"]/ul/li[1]/
            title = i.xpath('div/div/div[1]/a/text()')[0]
            totalPrice = i.xpath('div/div/div[6]/div[1]/span/text()')[0]
            position = i.xpath('div/div/div[2]/div/a/text()')[0].replace('\t','')
            position1 = i.xpath('div/div/div[2]/div/text()')[0]
            print(position,title,totalPrice+"万",position1)
            #
            # print(title,totalPrice)
        except Exception:
            pass


